#ifndef __DATABASE_H__
#define __DATABASE_H__

#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include "mqtt_json.h"
#include "cJSON.h"
#include "node.h"
#define TYPE_BOOL 1
#define TYPE_INT 2
#define TYPE_FLOAT 3


extern sqlite3 *db;

void database_init();
int insert_data_to_db(int key, int type, union val_t val, time_t ts);
int search_data_from_db(int key, time_t time_start, time_t time_end);
cJSON *search_data_to_json(int key, time_t time_start, time_t time_end);
#endif